﻿using System;
using System.Windows.Forms;
using GMap.NET;
using GMap.NET.EXT;
using GMap.NET.MapProviders;

namespace LeakView.view
{

    public partial class FormDownload : Form
    {
        private RectLatLng area;

        private GMapProvider provider;

        /*
        long tileCount = 0;

        long byteCount = 0;
        */

        private ZoomFetchers fetchers = new ZoomFetchers();
        
        public ZoomFetchers Fetchers { get => fetchers; }

        public FormDownload(RectLatLng area, GMapProvider provider)
        {
            this.area = area;
            this.provider = provider;
            InitializeComponent();
        }


        public void updateFetchers()
        {
            if(checkBox_world.Checked)
            {
                for (int i = 1; i <= 5; i++)
                {
                    fetchers[i].Area = Regions.world;
                }
            }

            if(checkBox_china.Checked)
            {
                for (int i = 6; i <= 9; i++)
                {
                    fetchers[i].Area = Regions.china;
                }
            }


            if(checkBox_area.Checked && !area.IsEmpty)
            {
                for (int i = 10; i <= (int)this.numericUpDown1.Value; i++)
                {
                    fetchers[i].Area = area;
                }
            }

            //this.labelMessage.Text = "共计下载：" + tileCount + "(" + byteCount + "KB)";


        }

        private void FormDownload_Load(object sender, EventArgs e)
        {
            updateFetchers();
        }

        private void checkBox_world_CheckedChanged(object sender, EventArgs e)
        {
            updateFetchers();
        }

        private void checkBox_china_CheckedChanged(object sender, EventArgs e)
        {
            updateFetchers();
        }

        private void checkBox_area_CheckedChanged(object sender, EventArgs e)
        {
            updateFetchers();
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            updateFetchers();
        }


    }


}
